﻿@{
    Layout = "~/Views/Shared/OA/_Index.cshtml";

    var isAdmin = ManagerAuthorization.Current.User.IsAdmin;
}
@section Toolbar
{
    @Html.MyNet().Button(new ButtonOptions { Text = "新建", Click = "create" })
    @Html.MyNet().Button(new ButtonOptions { Text = "修改", Click = "modify" })
    @Html.MyNet().Button(new ButtonOptions { Text = "删除", Click = "removee" })
}
@section Query
{
    @*@Html.Partial("_Query", new ArticleCondition())*@
}
@section Main
{
    <div id="grid" class="grid">
    </div>
    <div id="pager" class="pager">
    </div>
}
<script type="text/javascript">
    var url = "/CMS/Catalog/";
    var parentKey = '@Request["parentKey"]';

    jQuery(function () {
        read();
    });

    function read() {
        query.ParentKey = parentKey;
        $.ajax
            ({
                url: url + "ReadParentForWeb",
                data: query,
                type: "post",
                error: disposeError,
                success: function (result) {

                    if (disposeException(result)) return;
                    bind(result);
                }
            });
    }


    function create() {
        nav(url + "Create?parentKey=" + parentKey);
    }

    function modify() {
        if (!gridSelected()) return alert("未选中任何节点！");
        nav(url + "Modify?Id=" + gridSelected() + "&parentKey=" + parentKey);
    }


    function removee() {
        if (!gridSelected()) return alert("未选中任何节点！");
        if (!confirm("确定要删除选中的数据吗？")) return;

        $.ajax
            ({
                url: url + "Remove",
                data: { id: gridSelected() },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    reload(gridSelected());
                }
            });
    }

    function move(sourceId, destinationId, position) {
        $.ajax
            ({
                url: url + "Move",
                data: { sourceId: sourceId, destinationId: destinationId, position: position },
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                }
            });
    }

    //function detail() {
    //    $.ajax
    //        ({
    //            url: url + "Detail",
    //            data: { id: gridSelected() },
    //            type: "post",
    //            error: disposeError,
    //            success: function (result) {
    //                if (disposeException(result)) return;
    //                bind(result);
    //            }
    //        });
    //}

</script>
